<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增供应商货箱前缀管理')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-prefix-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">货箱前缀：</label>
            <div class="col-sm-8">
                <input name="prefix" id="prefix" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">货箱生产商：</label>
            <div class="col-sm-8">
                <input name="supplierCode" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefixUrl = ctx + "system/prefix"
    $("#form-prefix-add").validate({
        focusCleanup: true,
        rules: {
            onkeyup: false,
            prefix: {
                maxlength: 3
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            //$.operate.save(prefixUrl + "/add", $('#form-prefix-add').serialize());
            add();
        }
    }

    function add() {
        const formData = $('#form-prefix-add').serialize();
        $.ajax({
            cache : true,
            type : "POST",
            url : prefixUrl + "/add",
            data : formData,
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>